import axios from 'axios';

export default {
    namespaced: true,
    state: {
        goodsData: [],
        listdata: {
            currentPage: 1,
            pageSize: 5,
            totalCount: 0,
            totalPages: 0,

        }
    },

    mutations: {
        getlist(state, data) {
            state.goodsData = data.goodsData
            state.listdata = data
            console.log(data);


        },
        pageSize(state, data) {
            state.listdata.pageSize = data.pageSize
        },
        currentPage(state, data) {
            state.listdata.currentPage = data.currentPage
        }
    },
    actions: {
        update(state, data) {
            console.log(data)
            axios.post("/api/goods/update", data).then(res => { 
                console.log(res.data)
                // this.$router.replace('/system/goodslist')
             })
         },
        addgoods(state, data) {
            console.log(data)
            axios.post("/api/goods/add", data).then(res => { console.log(res.data) })
        },
        getlist(state, data) {
            console.log(data);
            
            axios.post("/api/goods/getlist", data).then(res => {
                console.log(res.data)
                state.commit("getlist", res.data)
            })
        },
        dle(state, data) {
            axios.post("/api/goods/dle", data).then(res => {
                console.log(res.data);

            })
        }
        // findShop() {
        //     axios.get("/api/shopManage/find", {
        //         params: data
        //     }).then(res => {
        //         console.log(res.data);
        //     })
        // }
    }
}